<%@include file="/pages/include/tag_include.jsp"%>
<%@include file="/pages/include/base_context.jsp"%>
<div class="container">
    <%@include file="/pages/include/message_display_include.jsp"%>


    <script>
        jQuery(document).ready(function($){
            $('#add-section').click(function(){
                $('#the-form').attr('action','<s:url value="/conferenceauthor/add_reviewer.do" />')
                $('#the-form').submit();
            });
        
            $('.btn-remove-line').click(function(){
                $('#selected-index').val($(this).attr('data'))
                $('#the-form').attr('action','<s:url value="/conferenceauthor/remove_reviewer.do" />')
                $('#the-form').submit();
            });
        
        });
    </script>

    <form id="the-form" class="form-horizontal" method="POST" action='<s:url value="/conferenceauthor/save.do"/>'>
        <input id="selected-index" type="hidden" name="form.selectedIndex" value="-1" />
        <input type="hidden" name="form.conferenceAuthor.conferenceId" value='<s:property value="%{form.conferenceAuthor.conferenceId}"/>' >
        <input type="hidden" name="form.conferenceAuthor.id" value='<s:property value="%{form.conferenceAuthor.id}"/>' >

        <div class="control-group">
            <label class="control-label" for="inputName"><s:text name="name" /></label>
            <div class="controls">
                <input readonly type="text" name="form.conferenceAuthor.conference.name" value='<s:property value="%{form.conferenceAuthor.conference.name}"/>' id="inputUsername" placeholder="Name">
            </div>
        </div>

        <div class="control-group">
            <label class="control-label" ><s:text name="reviewer" /></label>
            <div class="controls">
                <a id="add-section" href="javascript:void(0);" class="btn btn-info">Add</a>

                <table id="table-section" class="table table-striped">
                    <thead>
                    <th><s:text name="reviewer" /></th>
                    <th><s:text name="title" /></th>
                    <th><s:text name="description" /></th>
                    <th><s:text name="blind_review" /></th>
                    <th><s:text name="review_status" /></th>
                    <th>&nbsp;</th>
                    </thead>
                    <s:iterator value="form.conferenceAuthor.reviewer" var="item" status="row">
                        <s:set name="idx" value="#row.index" scope="page"/>
                        <tr>
                            <td>
                                <input type="hidden" name="form.conferenceAuthor.reviewer[<s:property value="#row.index" />].id" value="<s:property value="#item.id" />">
                                <input type="hidden" name="form.conferenceAuthor.reviewer[<s:property value="#row.index" />].conferenceAuthorId" value="<s:property value="#item.conferenceAuthorId" />">
                                <select name="form.conferenceAuthor.reviewer[<s:property value="#row.index" />].reviewerId">
                                    <s:iterator value="reviewers" var="reviewerItem">
                                        <option value="<s:property value="#reviewerItem.accountId" />"
                                                <s:if test="%{#item.reviewerId == #reviewerItem.accountId }">selected="selected"</s:if> >
                                            <s:property value="#reviewerItem.fullName" />
                                        </option>
                                    </s:iterator>
                                </select>
                            </td>


                            <td>
                                <input type="text" 
                                       name="form.conferenceAuthor.reviewer[<s:property value="#row.index" />].title" 
                                       value="<s:property value="#item.title"/>" 
                                       class="input-small"
                                       />
                            </td>

                            <td>
                                <input type="text" 
                                       name="form.conferenceAuthor.reviewer[<s:property value="#row.index" />].description" 
                                       value="<s:property value="#item.description"/>" 
                                       />
                            </td>

                            <td>
                                <input type="checkbox" 
                                       name="form.conferenceAuthor.reviewer[<s:property value="#row.index" />].blindReview" 
                                       value="true" 
                                       <s:if test="%{#item.blindReview}">checked</s:if> >
                            </td>



                            <td>
                                <s:if test="#item.inProgress">
                                    <span class="label label-warning"><s:text name="in_progress"/></span>
                                </s:if>
                                 <s:if test="#item.pending">
                                    <span class="label "><s:text name="pending"/></span>
                                </s:if>
                                <s:if test="#item.completed">
                                    <span class="label label-success"><s:text name="completed"/></span>
                                </s:if>
                            </td>

                            <td>
                                <a href="javascript:void(0);" 
                                   data='<s:property value="#row.index" />' class="btn btn-danger btn-remove-line" ><s:text name="remove"/></a>
                            </td>
                        </tr>


                    </s:iterator>
                </table>

            </div>
        </div>

        <center>
            <a href="<s:url value="/conferenceauthor/list.do"/>?form.conferenceAuthor.conferenceId=<s:property value="%{form.conferenceAuthor.conferenceId}"/>" class="btn btn-danger" ><s:text name="cancel"/></a>
            <input type="submit" value="<s:text name="save"/>" class="btn btn-success">
        </center>
    </form>

</div>
